package com.tianpengtech.admin.permission;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Model;
import com.tianpengtech.admin.AbstractAdminController;
import com.tianpengtech.admin.InitInterceptor;
import com.tianpengtech.admin.dictionary.DictionaryDao;
import com.tianpengtech.common.GlobalConfigConstant;
import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.common.model.dictionary.Dictionary;
import com.tianpengtech.common.model.permission.Permission;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;

/**
* 路由配置地址：add("/admin/permission", PermissionAdminController.class, "/admin/permission");
* 数据库映射地址：arp.addMapping(Permission.dao.tableName(),Permission.class);
*/
@Before(InitInterceptor.class)
//@RequiresRoles(GlobalConfigConstant.REQUIRES_ROLES_ADMIN)
@RequiresAuthentication
public class PermissionAdminController extends AbstractAdminController{

	@Override
	protected void config() {
		this.clazz=Permission.class;
		this.service=new PermissionAdminServiceImpl();
	}

	@Override
	public void beforeAdd(){

		setAttr("moduleList", DictionaryDao.ME.readParents(Dictionary.CONST_PERMISSION_CODE));
	}

	@Override
	public void beforeAdd(Model< ? > model) throws ValidateException {

	}

	@Override
	public void beforeQueryById(Model<?> model, int id) {
		setAttr("moduleList", DictionaryDao.ME.readParents(Dictionary.CONST_PERMISSION_CODE));
	}

	@Override
	public void beforeUpdate(Model< ? > model) throws ValidateException {

	}

	@Override
	public void beforeDelete(Model< ? > model) {

	}

}

	